package com.wl4837;

public class App
{
    public static void main( String[] args )
    {
        // 创建文件
        FileSystemComponent file1 = new File("Document.txt");
        FileSystemComponent file2 = new File("Image.jpg");
        FileSystemComponent file3 = new File("Spreadsheet.xlsx");
        FileSystemComponent file4 = new File("Program.java");

        // 创建子目录
        Directory subDir1 = new Directory("Work");
        subDir1.add(file1);
        subDir1.add(file3);

        Directory subDir2 = new Directory("Projects");
        subDir2.add(file4);

        // 创建根目录
        Directory rootDir = new Directory("Root");
        rootDir.add(subDir1);
        rootDir.add(subDir2);
        rootDir.add(file2);

        // 显示整个文件系统结构
        System.out.println("文件系统结构:");
        rootDir.display("");

        // 操作示例
        System.out.println("\n从Work目录删除Spreadsheet.xlsx:");
        subDir1.remove(file3);
        rootDir.display("");
    }
}
